<?php include('../../job/common/pdata_mysql.php'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>插入项目</title>
<style type="text/css">
.modi input {
	width: 350px;
	height: 30px;
}
.modi textarea {
	width: 350px;
	height: 50px;
}
.modi {
	font-size: 10px;
	width: 100%;
}
</style>
<link href="/css/allstyle.css" rel="stylesheet" type="text/css" />
</head>

<body>
<div id="header"><?php include("../../job/common/header.php") ?></div>
<div id="wrap">
  <div id="top">
    <h1>输变电工程:
    <?php $sql = "select projectname,oldname from project where pid = ".$_REQUEST['pid'];
	$conn = mysql_pconnect($hostname_pdata,$username_pdata,$password_pdata);
	mysql_select_db("pdata");
	$rs = mysql_query($sql,$conn);
	$row = mysql_fetch_array($rs);
	echo $row['projectname'];
	if($row['oldname']) echo "|曾用名:".$row['oldname'];
	?></h1>
  </div>
  <div id="middle">
	<?php
	if(isset($_REQUEST['pid']))
	{
		$pid = $_REQUEST['pid'];
		if(isset($_REQUEST['iname']))
		{
			$iname = $_REQUEST['iname'];
			$ptid = $_REQUEST['ptid'];
			$phid = $_REQUEST['phid'];
			$frm = $_REQUEST['frm'];
			$stid = $_REQUEST['stid'];
			$procode = $_REQUEST['procode'];
			$costclear = floatval($_REQUEST['costclear']);
			$coststat = floatval($_REQUEST['coststat']);
			$costdyn = floatval($_REQUEST['costdyn']);
	
			$sql = "INSERT INTO itemdetail (`pid`, `iname`, `ptid`, `phid`, `frm`, `stid`, `procode`, `costclear`, `coststat`, `costdyn`) VALUES (".$pid.",'".$iname."',".$ptid.",".$phid.",'".$frm."','".$stid."','".$procode."','".$costclear."','".$coststat."','".$costdyn."')";
			
			echo "<p>".$sql."</p>";
				
			$conn = mysql_pconnect($hostname_pdata,$username_pdata,$password_pdata);
			mysql_select_db("pdata");
			if($rs = mysql_query($sql,$conn) or die(mysql_error()))
			{
				echo "Insert Succeed!";
			}
			else
			{
				echo "Insert missed!Check the data and insert again!";
			}
		
			mysql_close($conn);
		}
	}
	else
	{
		$iname = "";
		$ptid = "";
		$phid = "";
		$frm = "";
		$stid = "1";//非变电站的默认为此数字
		$procode = "";
		$procode = "";
		$procode = "";
		$procode = "";
	}
	
		
	?>
    <form id="item" name="item" method="post" action="">
      <table class="modi">
        <tr>
          <th width="120">项目</th>
          <th width="360">内容</th>
          <th width="360">备注</th>
        </tr>
        <tr>
          <td>项目名称</td>
          <td><input name="iname" type="text" id="iname" value="<?php echo ""; ?>"  /></td>
          <td>填写项目名称</td>
        </tr>
        <tr>
          <td>阶段代码</td>
          <td><input name="phid" type="text" id="phid" value="<?php echo ""; ?>" /></td>
          <td>项目阶段（1-7）（可研1、可批2，初设3、初批4、施设5、竣工6、完工7）</td>
        </tr>
        <tr>
          <td>类型代码</td>
          <td><input name="ptid" type="text" id="ptid" value="<?php echo ""; ?>" /></td>
          <td>项目类型（1-9）（新建1、扩主变2、扩间隔3、保改4、架空5、电缆6、光缆7、光设8、其他9）</td>
        </tr>
        <tr>
          <td>数据来源</td>
          <td><input name="frm" type="text" id="frm" value="<?php echo ""; ?>" /></td>
          <td>来源名称（批文名，或者上报数字）</td>
        </tr>
        <tr>
          <td>变电站代码</td>
          <td><input name="stid" type="text" id="stid" value="<?php echo ""; ?>" /></td>
          <td>变电站工程序号（填写变电站序号，如果暂时未知默认为1）</td>
        </tr>
        <tr>
          <td>项目母代码</td>
          <td><input name="procode" type="text" id="procode" value="<?php echo ""; ?>" /></td>
          <td>项目所属院工程编号</td>
        </tr>
        <tr>
          <td>工程代码</td>
          <td><input name="pid" type="text" id="pid" value="<?php echo $pid; ?>" readonly="readonly" /></td>
          <td></td>
        </tr>
        <tr>
          <td>建场费用</td>
          <td><input name="costclear" type="text" id="costclear" value="<?php echo ""; ?>" /></td>
          <td></td>
        </tr>
        <tr>
          <td>静态投资</td>
          <td><input name="coststat" type="text" id="coststat" value="<?php echo ""; ?>" /></td>
          <td></td>
        </tr>
        <tr>
          <td>动态投资</td>
          <td><input name="costdyn" type="text" id="costdyn" value="<?php echo ""; ?>" /></td>
          <td></td>
        </tr>
      </table>
      <input name="insert" type="submit" class="modi" id="insert" value="插入" />
    </form>
  </div>
</div>
<div id="footer"><?php include("../../job/common/footer.php") ?></div>
</body>
</html>